--- export const prerender = false; import PageLayout from "@/layouts/Base.astro"; const { short_id } = Astro.params; const CELLAR_API_URL = import.meta.env.CELLAR_API_URL ?? "https://cellar.stevedylan.dev"; let wine: any = null; let fetchError: string | null = null; try { const res = await fetch(`${CELLAR_API_URL}/api/wines/${short_id}`); if (res.status === 404) { return Astro.redirect("/404"); } else if (!res.ok) { fetchError = `API returned ${res.status}`; } else { wine = await res.json(); } } catch (e) { fetchError = e instanceof Error ? e.message : "Failed to reach cellar API"; } const meta = { title: wine?.name ?? "Wine", description: wine ? `${wine.origin} · ${wine.grape}` : "", }; --- {fetchError ? ( Could not load wine: {fetchError} ) : wine && ( <> {wine.name} {wine.has_image && ( )} {!wine.wishlist && ( )} {wine.origin && ( origin {wine.origin} )} {wine.grape && ( grape {wine.grape} )} {wine.notes && ( notes {wine.notes} )} {wine.background && ( background {wine.background} )} > )} ← cellar
Could not load wine: {fetchError}
{wine.notes}
{wine.background}